<template>
  <el-button type="primary" @click="sendMiddle()" :loading="btnLoading">{{$t('middle.确认已送仓')}}</el-button>
</template>

<script>

import {sendMiddle} from "@/api/middleWork";

export default {
  name: "MiddleSendButton",
  props:{
    data: {
      type: Object,
      required: true,
      default: function(){
        return {};
      }
    }
  },

  data(){
    return {
      btnLoading: false,
    }
  },
  methods:{
    // 确认已送仓
    sendMiddle(){
      this.$confirm('',{
        title: this.$t('middle.确认已送仓？'),
      })
        .then(()=>{
          this.btnLoading = true
          sendMiddle(this.data.id)
            .then(res=>{
              this.btnLoading = false
              if(res.error === 0){
                this.$successMessage(res.message)
                this.$emit('sendMiddle')
              }else{
                this.$errorMessage(res.message)
              }
            })

        })
        .catch(_ => {});
    }


  },
}
</script>

<style scoped lang="scss">

</style>
